<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Click'N'Gage - Question #{questionDetailsManagedBean.questionID}</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" href="css/style.css" type="text/css" />
    </h:head>
    <h:body>
        <div id="container">
            <div id="wrapper">
                <div id="top">
                    <ui:include src="WEB-INF/includes/login.xhtml"/>
                </div>

                <ui:include src="WEB-INF/includes/navigation.xhtml"/>

                <div id="header">
                    <ui:include src="WEB-INF/includes/header.xhtml"/>
                </div>
                <div id="content">
                    <h1>Question #{questionDetailsManagedBean.questionID}</h1>
                    <blockquote><span class="open">&nbsp;</span>#{questionDetailsManagedBean.question.question}<span class="close">&nbsp;</span></blockquote>
                    <h:dataTable border="0" value="#{questionDetailsManagedBean.question.possibleAnswers}" var="answer">
                        <h:column>
                            <h:outputText value="#{answer.letter}" style="color: green; font-style: oblique" rendered="#{answer == questionDetailsManagedBean.question.correctAnswer}"/>
                            <h:outputText value="#{answer.letter}" rendered="#{answer != questionDetailsManagedBean.question.correctAnswer}"/>
                        </h:column>
                        <h:column>
                            <h:outputText value="#{answer.answerText}" style="color: green; font-style: oblique" rendered="#{answer == questionDetailsManagedBean.question.correctAnswer}"/>
                            <h:outputText value="#{answer.answerText}" rendered="#{answer != questionDetailsManagedBean.question.correctAnswer}"/>
                        </h:column>
                    </h:dataTable>
                    <h2>Success Rate</h2>
                    <h:graphicImage value="../timeseries/#{questionDetailsManagedBean.question.id}.png" style="padding: 1px; border: 1px; border-color: black; border-style: solid"/>
                    <h2>Issued instances</h2>
                    <h:form>
                        <h:dataTable border="0" value="#{questionDetailsManagedBean.question.answeredQuestions}" var="answeredQuestion">
                            <h:column>
                                <h4>Issue Code: #{answeredQuestion.questionCode}</h4>
                                Issued by: #{answeredQuestion.issuer.title} #{answeredQuestion.issuer.firstName} #{answeredQuestion.issuer.lastName}
                                on #{answeredQuestion.issueDate}
                                <p>
                                    Status: <h:outputText value="#{answeredQuestion.status}" style="color: green" rendered="#{answeredQuestion.status == 'ACTIVE'}" />
                                    <h:outputText value="#{answeredQuestion.status}" style="color: red" rendered="#{answeredQuestion.status == 'INACTIVE'}" />
                                </p>
                                <p>
                                    <h:commandLink value="Stop" action="#{issuedQuestionManagedBean.stopQuestionActionHandler}" rendered="#{answeredQuestion.status == 'ACTIVE'}">
                                        <f:setPropertyActionListener target="#{issuedQuestionManagedBean.issuedQuestionID}" value="#{answeredQuestion.id}" />
                                        <f:ajax execute="@form" render="@form"/>
                                    </h:commandLink>
                                </p>
                                <h:graphicImage value="../charts/#{answeredQuestion.questionCode}.png" style="padding: 1px; border: 1px; border-color: black; border-style: solid"/>
                                <br /><br />
                                <hr />
                            </h:column>
                        </h:dataTable>
                        <br /><br />
                        <h:messages styleClass="error" />
                        <h:outputText value="#{issuedQuestionManagedBean.errorMessage}" styleClass="error" rendered="#{issuedQuestionManagedBean.errorMessage != null}"/>
                    </h:form>
                </div>
                <div id="sidebar">
                    <h2>Quick Links</h2>
                    <ui:include src="WEB-INF/includes/quicklinks.xhtml"/>
                    <h2>Downloads</h2>
                    <ui:include src="WEB-INF/includes/download.xhtml"/>
                    <h2>Advertisments</h2>
                    <ui:include src="WEB-INF/includes/adsense.xhtml"/>
                </div>
                <div id="footer">
                    <ui:include src="WEB-INF/includes/footer.xhtml"/>
                </div>
            </div>
        </div>
    </h:body>
</html>
